<template>
  <a-modal
    title="账户信息"
    :visible="show"
    :footer="null"
    :width="800"
    @cancel="close"
  >
    <standard-table
      rowKey="userId"
      :columns="columns"
      :dataSource="info"
      :pagination="false"
      :loading="loading"
    >
      <div slot="userStat" slot-scope="{record}" >
        {{ record.userStat | getStatus }}
      </div>
    </standard-table>
  </a-modal>
</template>

<script>
import StandardTable from '@/components/table/StandardTable'
import {getAccountInfo} from '@/api/dianshang/dianshang'

export default{
  props:{
    show:Boolean,
    userName: String
  },
  data(){
    return{
      columns: [
        {
          title: '账户ID',
          dataIndex: 'userId',
        },
        {
          title: '账户名称',
          dataIndex: 'userName',
        },
        {
          title: '账户余额',
          dataIndex: 'balance',
        },
        {
          title: '账户日预算',
          dataIndex: 'budget',
        },
        {
          title: '账户状态',
          dataIndex: 'userStat',
          scopedSlots: { customRender: 'userStat' },
        },
      ],
      info:[],
      loading:false
    }
  },
  created(){
  },
  methods:{
    close(){
      this.$emit("update:show", false)
    },
    getInfo(){
      this.loading = true
      getAccountInfo({userName: this.userName}).then((res) => {
        this.loading = false
        if(res.errcode == 0){
          this.info = res.data
        }
      }).catch(() => {
        this.loading = false
      });
    },
  },
  watch:{
    show(status){
      if(status){
        this.getInfo()
      }else{
        this.info = []
      }
    }
  },
  filters:{
    getStatus(status){
      switch(status){
        case '1':case 1:
          return '账户暂未生效'
        case '2':case 2:
          return '账户生效'
        case '3':case 3:
          return '账户余额为零'
        case '4':case 4:
          return '账户被拒'
        case '5':case 5:
          return '账户预算不足'
        case '8':case 8:
          return '账户禁止投放'
        case '9':case 9:
          return '产品线暂未开通'
      }
    }
  },
  components:{StandardTable}
}
</script>

<style lang="less" scoped>

</style>